<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .area {
        width: 200px;
        height: 200px;
        background: red;
        margin: 10px 0;
      }
    </style>
  </head>

  <body>
    <div id="app"></div>
    <template id="pengfan">
      <!-- 完整写法： v-on:监听的事件="methods中方法" -->
      <button v-on:click="btn1Click">按钮1</button>
      <div class="area" v-on:mouseover="mouseMove">div</div>

      <!-- 语法糖 -->
      <button v-on:click="btn1Click">按钮1</button>
      <!-- 绑定一个表达式：inline statement -->
      <button @click="counter++">{{counter}}</button>
      <!-- 绑定一个对象 -->
      <div class="area" v-on="{click: btn1Click,mouseover:mouseMove}"></div>
      <div class="area" @="{click: btn1Click,mouseover:mouseMove}"></div>
    </template>
    <script src="../js/vue.js"></script>
    <script>
      Vue.createApp({
        template: "#pengfan",
        data() {
          return {
            message: "Hello World",
            counter: 100,
          };
        },
        methods: {
          btn1Click() {
            console.log("点击了按钮1");
          },
          mouseMove() {
            console.log("鼠标移动");
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
